const { Router } = require('express')
const express = require('express')
//路由容器
const footmark = express.Router()
const axios = require('axios')
const { JsonWebTokenError } = require('jsonwebtoken')
const jwt = require("jsonwebtoken")
footmark.get('/browse/queryAllBrose', (req, res) => {
    let {userId}=req.query
   axios({
        method:'get',
        url : '/browse/queryAllBrose',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            token:req.session.token
        },
        params:{
            userId:jwt.decode(req.session.token).id
        }
   }).then(function(data){
       res.status(200).json({
           data:data.data,
           code:0
       })
   }).catch(function(err){
       res.status(500).json({
           msg:err
       })
   })
})
footmark.delete('/browse/deleteSomeBrowse', (req, res) => {
    console.log(req.query)
    let {browseId}=req.query
    let delId='';
    for(let key of browseId){
        if(delId == ''){
            delId = delId + key
            console.log(delId)
            console.log(req.query)
        }else{
            delId = delId +',' + key;
            console.log(delId)
            console.log(req.query)
        }
    }
   axios({
        method:'delete',
        url : '/browse/deleteSomeBrowse',
        params:{
            browseId:delId
        }
   }).then(function(data){
       res.status(200).json({
           data:data.data,
           code:0
       })
   }).catch(function(err){
       res.status(500).json({
           msg:err
       })
   })
})

module.exports=footmark;